#include <iostream>
#include "TcpConnect.h"
#include "Acceptor.h"

using std::cout;
using std::endl;

void test()
{
    Acceptor acc("127.0.0.1", 12345);
    acc.init();
    int ret{};
    while (1)
    {
        TcpConnect tcp{acc.accept()};
        cout << tcp.toString() << endl;

        while (1)
        {
            cout << ">> msg from client: " << tcp.receive(ret);
            tcp.send("hello world!\n");
            if (ret == 0)
            {
                break;
            }
        }
        tcp.shutdown();
    }
}

int main(int argc, char const *argv[])
{
    test();
    return 0;
}
